﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.FactoryManagement;
using Digitalmes.Model.ProcessManagement;
using Digitalmes.Model.ProductManagement;

namespace Digitalmes.Model.IntegrationManagement
{
    /// <summary>
    /// 同步记录
    /// </summary>
	[Table("IntgrSyncRemote")]

    [Display(Name = "_Model.IntgrSyncRemote")]
    public class IntgrSyncRemote : TopBasePoco,IPersistPoco,ITenant
    {
        [Key]
        [Display(Name = "_Model._IntgrSyncRemote._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._Sn")]
        [Comment("追溯码")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Sn { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._TransSnId")]
        [Comment("流转号")]
        public long? TransSnId { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._ArchiveId")]
        [Comment("产品出站")]
        public long? ArchiveId { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._LineId")]
        [Comment("产线号")]
        public long? LineId { get; set; }

        public ProductionLine Line { get; set; }    


        [Display(Name = "_Model._IntgrSyncRemote._LineCode")]
        [Comment("产线编码")]
        public string LineCode { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._OpId")]
        [Comment("工位号")]
        public long? OpId { get; set; }

        public ProcessRouteItem Op { get; set; }        


        [Display(Name = "_Model._IntgrSyncRemote._OpCode")]
        [Comment("工位编码")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string OpCode { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._ErpOpCode")]
        [Comment("工厂工序编号")]
        public string ErpOpCode { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._PassResult")]
        [Comment("当前状态")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public SnStatusEnum? PassResult { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._Status")]
        [Comment("同步状态")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public RemoteSyncStatusEnum? Status { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._IsCompelted")]
        [Comment("完工下线")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool? IsCompelted { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._SyncMethod")]
        [Comment("同步方式")]
        public string SyncMethod { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._SyncCount")]
        [Comment("执行次数")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public int? SyncCount { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._ErrMessage")]
        [Comment("错误消息")]
        public string ErrMessage { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._CreatedTime")]
        [Comment("数据生成时间")]
        public DateTime? CreatedTime { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._IsFirst")]
        [Comment("首站")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool? IsFirst { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._StartTime")]
        [Comment("同步开始时间")]
        [NotMapped]
        public DateTime? StartTime { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._EndTime")]
        [Comment("同步结束时间")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public DateTime? EndTime { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._Remark")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._Wo")]
        [Comment("工单")]
        public string Wo { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._ProductId")]
        [Comment("产品号")]
        public long? ProductId { get; set; }

        public Product Product { get; set; }    

        [Display(Name = "_Model._IntgrSyncRemote._ProductName")]
        [Comment("产品名称")]
        public string ProductName { get; set; }
        [Display(Name = "_Model._IntgrSyncRemote._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
